macro(create_project_from_template _name)
    string(TOUPPER ${_name} _upper_name)
    string(REPLACE "-" "_" _upper_name ${_upper_name})

    file(GLOB_RECURSE ${_upper_name}_SOURCES LIST_DIRECTORIES false RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.cc" "*.c" "*.cpp")
    file(GLOB_RECURSE ${_upper_name}_HEADERS LIST_DIRECTORIES false RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.hh" "*.h" "*.hpp")
    foreach(fn_ ${${_upper_name}_SOURCES} ${${_upper_name}_HEADERS})
        get_filename_component(fd_ ${fn_} DIRECTORY)
        if(fd_)
            string(REPLACE "/" "\\" fd2_ "${fd_}")
            source_group("\\${fd2_}" FILES "${fn_}")
        else()
            source_group("\\" FILES "${fn_}")
        endif()
    endforeach()
    add_executable(${_name} ${${_upper_name}_SOURCES} ${${_upper_name}_HEADERS})
    add_dependencies(${_name} libevent libsodium libcurl)
    target_compile_definitions(${_name} PUBLIC -DSODIUM_STATIC -DCURL_STATICLIB)
    target_include_directories(${_name} BEFORE PRIVATE . ${CROSSROAD_STAGE_DIR}/include)
    target_link_libraries(${_name} ${CROSSROAD_DEP_LIBS} Threads::Threads)
    if(WIN32)
        target_link_libraries(${_name} ws2_32 crypt32)
        if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
            set_target_properties (${_name} PROPERTIES
                COMPILE_FLAGS "-static"
                LINK_FLAGS "-static")
        endif()
    endif()
endmacro()
